package com.itheima.controller;

import com.itheima.domain.Patients;
import com.itheima.service.SufferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/product")
public class SuffererSave {
    @Autowired
    private SufferService sufferService;

    @RequestMapping("/save")
    public String save(ModelAndView modelAndView, Patients patients) {
        System.out.println("controller..." + patients);
        sufferService.save(patients);
        return "/pages/subscribe-form.jsp";
    }

    @RequestMapping("/findAll")
    public String findAll(ModelAndView modelAndView) {
        System.out.println("SuffererSave...findAll()...");
        List<Patients> list = sufferService.findAll();
        System.out.println("list = " + list);
        modelAndView.addObject("content", list);
        return "forward:/pages/patients-list.jsp";
    }


    public void demo(){
        System.out.println("哈哈哈哈");

    }

}
